package com.czkevin.cif.crafting.ingredient;

import com.czkevin.cif.CIFItemInstance;
import com.czkevin.cif.CustomItemFramework;
import org.bukkit.inventory.ItemStack;

public class CIFCraftingIngredient implements CraftingIngredient {

    private final CIFItemInstance item;

    public CIFCraftingIngredient(CIFItemInstance item) {
        if(item == null) throw new IllegalArgumentException("Invalid CIFItemInstance! ");
        this.item = item;
    }

    @Override
    public boolean matches(ItemStack target) {
        if(target == null) return false;
        CIFItemInstance targetCIFInstance = CustomItemFramework.getCIFDataFromItem(target);
        if(targetCIFInstance == null) return false;
        return item.type.isSimilar(item, targetCIFInstance);
    }

    @Override
    public int getAmount() {
        return 1;
    }
}
